package com.defang.application;

import com.defangit.applicant.domain.Enroll;
import com.defangit.applicant.orm.EnrollService;

import javax.ws.rs.*;
import java.util.List;

/**
 * Created by Administrator on 2019/3/13.
 */
@Path("enroll")
public class EnrollResource {
    EnrollService enrollService = new EnrollService();
    @GET
    @Produces("application/json")
    public List<Enroll> enrollall(){
        return enrollService.all();
    }
    @GET
    @Path("{id}")
    @Produces("application/json")
    public List<Enroll> enroll(@PathParam("id") int enrollId,
                               @QueryParam("orgId") int orgId){
        return enrollService.findAll()
                .enrollId(enrollId)
                .orgid(orgId)
                .matchedAll();
    }
    @POST
    @Consumes("application/json")
    public boolean addEnroll(Enroll enroll){
        return enrollService.addEnroll(enroll)!=null;
    }
    @POST
    @Path("{id}")
    @Consumes("application/json")
    public Enroll updateEnroll(@PathParam("id") Integer enrollid,Enroll enroll){
        return enrollService.updateEnroll(enroll);
    }
    @DELETE
    @Path("{id}")
    public boolean delEnroll(@PathParam("id") Integer id){
        return enrollService.delEnroll(id);
    }
}
